package com.dk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dk.pojo.Partanduser;
import com.dk.mapper.PartanduserMapper;
import com.dk.service.IPartanduserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2022-07-19
 */
@Service
public class PartanduserServiceImpl extends ServiceImpl<PartanduserMapper, Partanduser> implements IPartanduserService {

    @Autowired
    private PartanduserMapper partanduserMapper;
    @Override
    public Integer deleIpart(List<Integer> partList) {
        QueryWrapper<Partanduser> queryWrapper=new QueryWrapper<>();
        queryWrapper.in("partid",partList);
        return partanduserMapper.delete(queryWrapper);
    }

    @Override
    public List<Integer> getPart(Integer userid) {
        QueryWrapper<Partanduser> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("userid",userid);
        List<Partanduser> list = partanduserMapper.selectList(queryWrapper);
        List<Integer> collect = list.stream().map(Partanduser::getPartid).collect(Collectors.toList());

        return collect;
    }
}
